import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

import XUI 1.0

Rectangle {
    id:     testRoot
    color:  "grey"
    property bool checktest : false
    property real _margin:    XScreenTool.base
    property color _titleC:     "yellow"
    property color _spacingC:   "#bb000000"

    Column  {
        id: grid
        anchors.fill: parent
        anchors.margins: 12
        spacing:  _margin

        XLabel {
            text: "Label 演示" ;
            color: _titleC
            anchors.horizontalCenter: parent.horizontalCenter
            // Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
        }

        Row {
            anchors.horizontalCenter: parent.horizontalCenter
            spacing: _margin
            XLabel {
                text: "XLabel" ;
            }

            Item {
                width: 1
                height: 1
            }

            XLabelOutline {
                text: "外发光字体" ;
            }
        }

        Rectangle {
            width: parent.width * 0.8
            anchors.horizontalCenter: parent.horizontalCenter
            color:  _spacingC
            height: 1.0
        }

        //================================"Button 演示"================================
        XLabel {
            text: "Button 演示" ;
            anchors.horizontalCenter: parent.horizontalCenter
            color:   _titleC
            // Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
        }

        Row {
            anchors.horizontalCenter: parent.horizontalCenter
            spacing: _margin/3
            XLabel {
                text: "XButtonLabel" ;
                anchors.verticalCenter: parent.verticalCenter
                // Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
            }

            XButtonLabel {
                // height:     parent.height //
                // width:      height * 1
                anchors.verticalCenter: parent.verticalCenter
                text:     "Button"
                onClicked: {

                }
            }

            Item {
                width: 1
                height: 1
            }

            XLabel {
                text: "XButtonImage" ;
                anchors.verticalCenter: parent.verticalCenter
                // Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
            }

            XButtonImage {
                source:     "qrc:/image/XSat.png"
                anchors.verticalCenter: parent.verticalCenter
                onClicked: {

                }
            }
            Item {
                width: 1
                height: 1
            }

            XLabel {
                text: "XButtonImageRectangle" ;
                anchors.verticalCenter: parent.verticalCenter
                // Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
            }

            XButtonImageRectangle {
                height:     parent.height * 0.8
                width:      height * 1
                anchors.verticalCenter: parent.verticalCenter
                source:     "qrc:/image/XSat.png"
                onClicked: {
                }
            }
            Item {
                width: _margin
                height: 1
            }

            XLabel {
                text: "XButtonColumnImageLabel" ;
                anchors.verticalCenter: parent.verticalCenter
                // Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
            }
            Rectangle {
                color:  "white"
                width:   imageLabel1.width + _margin * 2
                height:  imageLabel1.height + _margin * 2
                radius:     _margin
                anchors.verticalCenter: parent.verticalCenter
                XButtonColumnImageLabel {
                    id:                     imageLabel1
                    anchors.centerIn:       parent
                    text:                   "路网"  //路网+标注
                    isMapItem:              true
                    imageC:                 "#ffffff"
                    source:                 "qrc:/image/Street.png"
                    checked:                checktest
                    onClicked:  {
                        checktest = !checktest
                        console.log("提交被点击")
                    }
                }
            }
        }

        Rectangle {
            width: parent.width * 0.8
            anchors.horizontalCenter: parent.horizontalCenter
            color:  _spacingC
            height: 1.0
        }

        //================================"Button2 演示"================================
        Row {
            anchors.horizontalCenter: parent.horizontalCenter
            XLabel {
                text: "XButtonColoredImageLabelRow" ;
                anchors.verticalCenter: parent.verticalCenter
            }

            XButtonColoredImageLabelRow {
                text:       "卫星"
                source:     "qrc:/image/XSat.png"
                onClicked: {

                }
            }
            Item {
                width: _margin
                height: 1
            }

            XLabel {
                text: "XButtonImageLabelRow"
                anchors.verticalCenter: parent.verticalCenter
            }

            XButtonImageLabelRow {
                text:       "卫星"
                source:     "qrc:/image/XSat.png"
                anchors.verticalCenter: parent.verticalCenter
            }
        }

        //================================"ComboBox 演示"================================

        Rectangle {
            width: parent.width * 0.8
            anchors.horizontalCenter: parent.horizontalCenter
            color:  _spacingC
            height: 1.0
        }

        XLabel {
            text: "ComboBox 演示" ;
            anchors.horizontalCenter: parent.horizontalCenter
            color:   _titleC
            // Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
        }
        Row {
            anchors.horizontalCenter: parent.horizontalCenter
            spacing:  _margin/2
            XLabel {
                text: "XComboBox" ;
                anchors.verticalCenter: parent.verticalCenter
            }
            XComboBox {
                model:      modelList
            }

            Item {
                width: 1
                height: 1
            }

            XLabel {
                text: "XSwitch" ;
                anchors.verticalCenter: parent.verticalCenter
            }
            XSwitch {
                height: _margin * 3
                width:  _margin * 7
                anchors.verticalCenter: parent.verticalCenter
                onToggled: {
        //            console.log("QGroundControl.settingsManager.appSettings.virtualJoystick = ", fact.rawValue)
                }
            }

            Item {
                width: 1
                height: 1
            }
            XLabel {
                text: "XTextField" ;
                anchors.verticalCenter: parent.verticalCenter
            }
            XTextField {
                anchors.verticalCenter: parent.verticalCenter
        //            console.log("QGroundControl.settingsManager.appSettings.virtualJoystick = ", fact.rawValue)
            }
        }

        //================================"Slider 演示"================================

        Rectangle {
            width: parent.width * 0.8
            anchors.horizontalCenter: parent.horizontalCenter
            color:  _spacingC
            height: 1.0
        }

        XLabel {
            text: "XSliderSwitch" ;
            anchors.horizontalCenter: parent.horizontalCenter
            color:   _titleC
            // Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
        }
        Row {
            anchors.horizontalCenter: parent.horizontalCenter
            spacing:  _margin/2
            width: parent.width
            x:    width * 0.3
            Item {
                width: 1
                height: 1
            }
            XLabel {
                text: "XSliderSwitch" ;
                anchors.verticalCenter: parent.verticalCenter
            }
            XSliderSwitch {
                width:                      parent.width * 0.3
                anchors.verticalCenter:     parent.verticalCenter
                _unit:                      "m/s"
                _name:                      qsTr("航线速度")  //qsTr("Speed")航线速度
                _valueMin:                  0.5
                _valueMax:                  10.0
                presion:                    1
                _defaultValue:              _testValue
                onUpValue:            {
                    speed.restart();
                    _sliderValue = value
                    _testValue = _sliderValue
                    console.log("ZHSliderSwitch speed1: ", _sliderValue)
                }
            }

        }
    //     TextField { placeholderText: "请输入姓名"; Layout.fillWidth: true }

    //     // Button
    //
    //     // 你可以自由放任意组件，GridLayout 会按列数排列
    //     Label { text: "邮箱" }
    //     TextField { placeholderText: "请输入邮箱"; Layout.fillWidth: true }
    //     Button { text: "清空"; onClicked: console.log("清空") }

    //     Label { text: "备注"; Layout.columnSpan: 1 }
    //     TextArea { Layout.rowSpan: 2; Layout.columnSpan: 2; placeholderText: "备注..." }
    }

    property var modelList : ["卫星","路网","混合地图"]
    property real _testValue: 5
    property real _sliderValue//speedValue

    Timer {
        id:         speed
        interval:   300;
        running:    false;
        repeat:     false
        onTriggered:    {
            _testValue = _sliderValue
            console.log("_testValue",  _testValue)
        }
    }
}
